using System;
using System.Linq.Expressions;
using System.Web.Mvc;
using Microsoft.Web.Mvc.Internal;
namespace Coderoom.ScrumPlanner.Web
{
	public abstract class CoderoomController : Controller
	{
		protected ActionResult View<TController>(Expression<Action<TController>> action) where TController : Controller
		{
			var viewMethod = ((MethodCallExpression)(action.Body)).Method;

			return View(viewMethod.Name);
		}

		protected ActionResult RedirectToAction<TController>(Expression<Action<TController>> action) where TController : Controller
		{
			var viewMethod = ((MethodCallExpression)(action.Body)).Method;
			var routeValues = ExpressionHelper.GetRouteValuesFromExpression(action);

			return RedirectToAction(viewMethod.Name, routeValues);
		}
	}
}